﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsXuatChuyenKhoChiTiet
    {
        private double mGiaVon = 0.0;
        private double mGiaVonNT = 0.0;
        private string mHanSuDung = "";
        private string mKhoa = "";
        private string mKhoaDonViTinh = "";
        private string mKhoaHangHoa = "";
        private string mKhoaKhoNhap = "";
        private string mKhoaKhoXuat = "";
        private string mKhoaPhieuXuat = "";
        private string mKhoaQuayKeNhap = "";
        private string mKhoaQuayKeXuat = "";
        private string mNgayNhap = "";
        private string mNgayXuatChuyen = "";
        private double mQuyCach = 0.0;
        private string mSoLoHang = "";
        private double mSoLuong = 0.0;
        private string mSoSeri = "";
        private double mTienVon = 0.0;
        private double mTienVonNT = 0.0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM ST_XuatChuyenChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaPhieuXuat = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mNgayXuatChuyen = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangHoa = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKhoXuat = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mKhoaQuayKeXuat = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mKhoaKhoNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mKhoaQuayKeNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mSoLoHang = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mNgayNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mHanSuDung = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mSoSeri = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mSoLuong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mGiaVonNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetDecimal));
                    this.mGiaVon = Conversions.ToDouble(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienVonNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienVon = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaDonViTinh = Conversions.ToString(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetString));
                    this.mQuyCach = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetDecimal));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x13];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaPhieuXuat", DbType.Int64, ParameterDirection.Input, this.mKhoaPhieuXuat);
                commandParameters[2] = DBHelper.createParameter("@NgayXuatChuyen", DbType.Int64, ParameterDirection.Input, this.mNgayXuatChuyen);
                commandParameters[3] = DBHelper.createParameter("@KhoaHangHoa", DbType.Int64, ParameterDirection.Input, this.mKhoaHangHoa);
                commandParameters[4] = DBHelper.createParameter("@KhoaKhoXuat", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoXuat);
                commandParameters[5] = DBHelper.createParameter("@KhoaQuayKeXuat", DbType.Int64, ParameterDirection.Input, this.mKhoaQuayKeXuat);
                commandParameters[6] = DBHelper.createParameter("@KhoaKhoNhap", DbType.Int64, ParameterDirection.Input, this.mKhoaKhoNhap);
                commandParameters[7] = DBHelper.createParameter("@KhoaQuayKeNhap", DbType.Int64, ParameterDirection.Input, this.mKhoaQuayKeNhap);
                commandParameters[8] = DBHelper.createParameter("@SoLoHang", DbType.Int64, ParameterDirection.Input, this.mSoLoHang);
                commandParameters[9] = DBHelper.createParameter("@NgayNhap", DbType.Int64, ParameterDirection.Input, this.mNgayNhap);
                commandParameters[10] = DBHelper.createParameter("@HanSuDung", DbType.Int64, ParameterDirection.Input, this.mHanSuDung);
                commandParameters[11] = DBHelper.createParameter("@SoSeri", DbType.Int64, ParameterDirection.Input, this.mSoSeri);
                commandParameters[12] = DBHelper.createParameter("@SoLuong", DbType.Date, ParameterDirection.Input, this.mSoLuong);
                commandParameters[13] = DBHelper.createParameter("@GiaVonNT", DbType.Date, ParameterDirection.Input, this.mGiaVonNT);
                commandParameters[14] = DBHelper.createParameter("@GiaVon", DbType.Date, ParameterDirection.Input, this.mGiaVon);
                commandParameters[15] = DBHelper.createParameter("@TienVonNT", DbType.Date, ParameterDirection.Input, this.mTienVonNT);
                commandParameters[0x10] = DBHelper.createParameter("@TienVon", DbType.Date, ParameterDirection.Input, this.mTienVon);
                commandParameters[0x11] = DBHelper.createParameter("@KhoaDonViTinh", DbType.Int64, ParameterDirection.Input, this.mKhoaDonViTinh);
                commandParameters[0x12] = DBHelper.createParameter("@QuyCach", DbType.Date, ParameterDirection.Input, this.mQuyCach);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_XuatChuyenKhoChiTiet", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public double GiaVon
        {
            get
            {
                return this.mGiaVon;
            }
            set
            {
                this.mGiaVon = value;
            }
        }

        public double GiaVonNT
        {
            get
            {
                return this.mGiaVonNT;
            }
            set
            {
                this.mGiaVonNT = value;
            }
        }

        public string HanSuDung
        {
            get
            {
                return this.mHanSuDung;
            }
            set
            {
                this.mHanSuDung = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaDonViTinh
        {
            get
            {
                return this.mKhoaDonViTinh;
            }
            set
            {
                this.mKhoaDonViTinh = value;
            }
        }

        public string KhoaHangHoa
        {
            get
            {
                return this.mKhoaHangHoa;
            }
            set
            {
                this.mKhoaHangHoa = value;
            }
        }

        public string KhoaKhoNhap
        {
            get
            {
                return this.mKhoaKhoNhap;
            }
            set
            {
                this.mKhoaKhoNhap = value;
            }
        }

        public string KhoaKhoXuat
        {
            get
            {
                return this.mKhoaKhoXuat;
            }
            set
            {
                this.mKhoaKhoXuat = value;
            }
        }

        public string KhoaPhieuXuat
        {
            get
            {
                return this.mKhoaPhieuXuat;
            }
            set
            {
                this.mKhoaPhieuXuat = value;
            }
        }

        public string KhoaQuayKeNhap
        {
            get
            {
                return this.mKhoaQuayKeNhap;
            }
            set
            {
                this.mKhoaQuayKeNhap = value;
            }
        }

        public string KhoaQuayKeXuat
        {
            get
            {
                return this.mKhoaQuayKeXuat;
            }
            set
            {
                this.mKhoaQuayKeXuat = value;
            }
        }

        public string NgayNhap
        {
            get
            {
                return this.mNgayNhap;
            }
            set
            {
                this.mNgayNhap = value;
            }
        }

        public string NgayXuatChuyen
        {
            get
            {
                return this.mNgayXuatChuyen;
            }
            set
            {
                this.mNgayXuatChuyen = value;
            }
        }

        public double QuyCach
        {
            get
            {
                return this.mQuyCach;
            }
            set
            {
                this.mQuyCach = value;
            }
        }

        public string SoLoHang
        {
            get
            {
                return this.mSoLoHang;
            }
            set
            {
                this.mSoLoHang = value;
            }
        }

        public double SoLuong
        {
            get
            {
                return this.mSoLuong;
            }
            set
            {
                this.mSoLuong = value;
            }
        }

        public string SoSeri
        {
            get
            {
                return this.mSoSeri;
            }
            set
            {
                this.mSoSeri = value;
            }
        }

        public double TienVon
        {
            get
            {
                return this.mTienVon;
            }
            set
            {
                this.mTienVon = value;
            }
        }

        public double TienVonNT
        {
            get
            {
                return this.mTienVonNT;
            }
            set
            {
                this.mTienVonNT = value;
            }
        }
    }
}

